import request from '@/utils/request'

/* 封装登录login函数 */
export const loginForm = (loginform) => {
  return request({
    url: '/api/login',
    method: 'post',
    data: loginform
  })
}

/* 封装注册函数 */
export const regForm = (loginform) => {
  return request({
    url: '/api/reg',
    method: 'post',
    data: loginform
  })
}

// 获取用户信息
export const getUserInfoApi = () => {
  return request({
    url: '/my/userinfo',
    method: 'get'
  })
}

// 提交修改用户信息
export const updateUserInfoApi = data => {
  return request({
    url: '/my/userinfo',
    method: 'put',
    data
  })
}

// 更新用户密码
export const updatedpwd = data => {
  return request({
    url: '/my/updatepwd',
    method: 'patch',
    data
  })
}

// 上传头像
export const reqUpdateAvatar = avatar => {
  return request({
    method: 'patch',
    url: '/my/update/avatar',
    data: {
      avatar
    }
  })
}
